home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / easyproc2.lha / EasyProcess / launch / ChildEntry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.3 KB  |  64 lines

  1. #include "Launch.h"
  2. #include "LaunchPriv.h"
  3.  
  4.  
  5. /*
  6.  *    NAME
  7.  *        ChildEntry -- used when starting processes.
  8.  *
  9.  *    SYNOPSIS
  10.  *        ChildEntry ()
  11.  *
  12.  *    FUNCTION
  13.  *        Call the process' entry point with its data.
  14.  *
  15.  *    DESCRIPTION
  16.  *        It load the A4 register, find the process pair (parent/child),
  17.  *        allocate the child's kill signal and then call the child entry
  18.  *        point with the data given by the parent.  On exit, it clears
  19.  *        the entry point and signal the parent.
  20.  *
  21.  *    INPUT
  22.  *        None.
  23.  *
  24.  *    OUTPUT
  25.  *        None.
  26.  *
  27.  *    NOTE
  28.  *        We currently use the break C signal as the kill signal.  This
  29.  *        let the user kill the process himself (if anything should go
  30.  *        wrong...).
  31.  *
  32.  *    HISTORY
  33.  *        1992/09/06    Pierre Baillargeon        Creation
  34.  *        1992/09/07    Pierre Baillargeon        Correction
  35.  *                    Now, the node removal and memory freeing is done
  36.  *                    in the parent.  Otherwise the parent signal bit
  37.  *                    would not always be freed.
  38.  *
  39.  *    SEE ALSO
  40.  *        StartProcess()
  41.  */
  42.  
  43. void __saveds ChildEntry (void)
  44. {
  45.     struct ProcPair *pp;
  46.     struct Process *Proc;
  47.  
  48.     Proc = (struct Process *)FindTask (NULL);
  49.     Wait (1L << Proc->pr_MsgPort.mp_SigBit);
  50.  
  51.     Forbid ();
  52.     pp = IsChild (Proc);
  53.     Permit ();
  54.  
  55.     if (pp)
  56.     {
  57.         pp->pp_ChildBit = AllocSignal (KILL_PROCESS_FLAG);
  58.         pp->pp_ChildEntry (pp->pp_ChildData);
  59.         Forbid ();
  60.         pp->pp_ChildEntry = NULL;
  61.         Signal (pp->pp_Parent, 1L << pp->pp_ParentBit);
  62.     }
  63. }
  64.